package com.wasion.gydpe.action;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

import com.wasion.gydpe.service.ZoneAreaMonitorService;

/**
 * 
 * @ClassName: ZoneAreaMonitorAction
 * @Description: 台区监控模块的控制层Action，涵盖的功能点包括：
 *               <p>
 *               1. 有功功率曲线；2. 无功功率曲线；3. 功率因数曲线；
 *               </p>
 *               <p>
 *               4. 电压曲线；5. 电流曲线；6. 零序电流曲线
 *               </p>
 *               <p>
 *               7. 有功总电能量曲线；8. 无功总电能量曲线；9. 有功总电能示值曲线；
 *               </p>
 *               <p>
 *               10. 无功总电能示值曲线
 *               </p>
 * @author 高意
 * @date Aug 28, 2012 2:57:16 PM
 * 
 */
@ParentPackage("struts-default")
@Namespace("/zoneAreaMonitor")
@Results( {
		@Result(name = "list_success", location = "/jsp/tqjk/zoneAreaMonitorList.jsp"),
		@Result(name = "activer_power_success", location = "/jsp/tqjk/activePowerCurve.jsp"),
		@Result(name = "lineListSuccess", location = "/jsp/archivesMgmt/lineMgmt.jsp"),
		@Result(name = "terminalListSuccess", location = "/jsp/archivesMgmt/terminalMgmt.jsp"),
		@Result(name = "indicatorListSuccess", location = "/jsp/archivesMgmt/indicatorMgmt.jsp"),
		@Result(name = "error", location = "/jsp/common/error/error.jsp") })
@ExceptionMappings( { @ExceptionMapping(exception = "java.lang.Exception", result = "error") })
@Controller
public class ZoneAreaMonitorAction {

	private static final long serialVersionUID = 3243242343L;

	/**
	 * Action执行成功返回值
	 */
	private static final String ACTIVER_POWER_SUCCESS = "activerPowerSuccess";// 有功功率
	private static final String REACTIVER_POWER_SUCCESS = "reactiverPowerSuccess";// 无功功率
	private static final String POWER_FACTOR_SUCCESS = "powerFactorSuccess";// 功率因素
	private static final String VOLTAGE_SUCCESS = "voltageSuccess";// 电压
	private static final String CURRENT_SUCCESS = "currentSuccess";// 电流
	private static final String ZERO_SEQUENCE_CURRENT_SUCCESS = "zeroSequenceCurrentSuccess";// 零序电流
	private static final String ACTIVE_POWER_ENERGY_SUCCESS = "activePowerEnergySuccess";// 有功总电能量
	private static final String REACTIVE_POWER_ENERGY_SUCCESS = "reactivePowerEnergySuccess";// 无功总电能量
	private static final String ACTIVE_POWER_INDICATION_SUCCESS = "activePowerIndicationSuccess";// 有功总电能示数
	private static final String REACTIVE_POWER_INDICATION_SUCCESS = "reactivePowerIndicationSuccess";// 无功总电能示数

	/**
	 * 台区监控标示
	 */
	private String flag = "";

	/**
	 * 区台监控服务接口
	 */
	@Resource
	private ZoneAreaMonitorService zoneAreaMonitorService;

	// 终端地址
	private String terminalAddr = "";

	public String getTerminalAddr() {
		return terminalAddr;
	}

	public void setTerminalAddr(String terminalAddr) {
		this.terminalAddr = terminalAddr;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	@Action("list")
	public String list() {
		return "list_success";
	}

	/**
	 * 描述：显示有功功率曲线
	 */
	@Action("showActivePowerCurve")
	@SuppressWarnings("unchecked")
	public String showActivePowerCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showActivePowerCurve(paramsMap);

		return "activer_power_success";
	}

	/**
	 * 描述：显示无功功率曲线
	 */
	@SuppressWarnings("unchecked")
	public String showReactivePowerCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showReactivePowerCurve(paramsMap);

		return REACTIVER_POWER_SUCCESS;
	}

	/**
	 * 描述：显示功率因数曲线
	 */
	@SuppressWarnings("unchecked")
	public String showPowerFactorCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showPowerFactorCurve(paramsMap);

		return POWER_FACTOR_SUCCESS;
	}

	/**
	 * 描述：显示电压曲线
	 */
	@SuppressWarnings("unchecked")
	public String showVoltageCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showVoltageCurve(paramsMap);

		return VOLTAGE_SUCCESS;
	}

	/**
	 * 描述：显示电流曲线
	 */
	@SuppressWarnings("unchecked")
	public String showCurrentCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showCurrentCurve(paramsMap);

		return CURRENT_SUCCESS;
	}

	/**
	 * 描述：显示零序电流曲线
	 */
	@SuppressWarnings("unchecked")
	public String showZeroSequenceCurrentCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showZeroSequenceCurrentCurve(paramsMap);

		return ZERO_SEQUENCE_CURRENT_SUCCESS;
	}

	/**
	 * 描述：显示有功总电能量曲线
	 */
	@SuppressWarnings("unchecked")
	public String showActivePowerEnergyCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showActivePowerEnergy(paramsMap);

		return ACTIVE_POWER_ENERGY_SUCCESS;
	}

	/**
	 * 描述：显示无功总电能量曲线
	 */
	@SuppressWarnings("unchecked")
	public String showReactivePowerEnergyCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showReactivePowerEnergy(paramsMap);

		return REACTIVE_POWER_ENERGY_SUCCESS;
	}

	/**
	 * 描述：显示有功总电能示数曲线
	 */
	@SuppressWarnings("unchecked")
	public String showActivePowerIndicationCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showActivePowerIndication(paramsMap);

		return ACTIVE_POWER_INDICATION_SUCCESS;
	}

	/**
	 * 描述：显示无功总电能示数曲线
	 */
	@SuppressWarnings("unchecked")
	public String showReactivePowerIndicationCurve() {

		Map paramsMap = new HashMap();
		paramsMap.put("terminalAddr", terminalAddr);
		zoneAreaMonitorService.showReactivePowerIndication(paramsMap);

		return REACTIVE_POWER_INDICATION_SUCCESS;
	}

}
